package com.shundr.common.view;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.shundr.R;
/**
 * 拨打客服电话
 * @author Administrator
 *
 */
public class DialogCall extends Dialog {
	private Context context;
	private TextView tvPhoneNumber;
	private Button btnCallPhoneSure;
	private Button ivNotCallPhone;
	private TextView tvTitle;
	
	public DialogCall(Context context) {
		super(context, R.style.dialog_style);
		this.context = context;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_dialog_call_service_phone);
		tvTitle=(TextView)findViewById(R.id.tv_call_title);
		tvPhoneNumber = (TextView) findViewById(R.id.tv_service_phone_show);
		btnCallPhoneSure = (Button) findViewById(R.id.btn_call_phone_sure);
		ivNotCallPhone= (Button) findViewById(R.id.iv_not_to_call_phone);
		tvTitle.setText("联系客服");
		tvPhoneNumber.setText(R.string.customer_service_phone);
		setCanceledOnTouchOutside(true);
		btnCallPhoneSure.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
				try {
					String mobileText = tvPhoneNumber.getText().toString();
					Intent intent = new Intent();// 创建一个意图对象，用来激发拨号的Activity
					intent.setAction("android.intent.action.CALL");
					intent.setData(Uri.parse("tel:"+ mobileText));
					context.startActivity(intent);// 方法内部会自动添加类别,android.intent.category.DEFAULT
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});

		ivNotCallPhone.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}
}
